<template>
  <div>
    <x-header id="header" :left-options="{backText: ''}">修改姓名</x-header>
    <div class="main-header">
      <div class="name-input">
        <x-input class="input" title="姓名" placeholder="请输入姓名" type="text" v-model="name">
          <div class="input-label" slot="label">姓名</div>
        </x-input>
      </div>
      <div class="save">
        <x-button class="save-button" @click.native="editNameHandle">确认</x-button>
      </div>
    </div>
  </div>
</template>

<script>
import { editName } from '@/api/user'
export default {
  name: 'name',
  data () {
    return {
      name: ''
    }
  },
  components: {
  },
  methods: {
    editNameHandle () {
      editName({cid: this.globalData.cid, name: this.name}).then( () => {
        this.$vux.toast.show({
          text: '修改成功',
          type: 'success'
        })
        setTimeout(() => {
          this.$router.back(-1)
        },1500)
      })
    }
  }
}
</script>

<style scoped>
.name-input {
  background: #fff;
}

</style>
